package org.ku.hero.util;

import org.ku.hero.api.protocol.Command;
import org.ku.hero.api.protocol.Const;
import org.ku.hero.api.protocol.Packet;
import org.ku.hero.body.LoginData;

public class PacketUtil {

    /**
     * 客户端发送心跳包
     */
    public static Packet heartBeatPackge(String vin){
        Packet packet = new Packet(Command.HEART_BEAT);
        packet.setAck(Const.ACK_SUCC);
        packet.setVin(vin);
        packet.setEncry(Const.ENCRY_NO);
        packet.setLength((short)0);
        return packet;
    }

    /**
     * 服务端返回应答包
     * 只需变更应答标志
     */
    public static Packet heartBeatAck(Packet packet){
        packet.setAck(Const.ACK_SUCC);
        return packet;
    }

    /**
     * 客户端发送登录包
     * @return
     */
    public static Packet loginPackage(String vin,LoginData loginData){
        Packet packet = new Packet(Command.VEHICLE_LOGIN);
        packet.setAck(Const.ACK_CMD);
        packet.setVin(vin);
        packet.setEncry(Const.ENCRY_NO);

        return packet;
    }


}
